home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 14 / Mac Magazin and MacEasy Magazine CD - Issue 14.iso / Wissenschaft & Technik / Tools Plus 2.6.1 Evaluation Kit / Tools Plus 2.6.1 / Tutorials / 5-Pop-Up Menus / About… Pop-Up Menus next >
INI File  |  1995-08-01  |  3KB  |  41 lines

  1. [Display in Geneva 12pt]
  2.  
  3.  
  4.  
  5. Pop-Up Menus
  6. ~~~~~~~~~~~
  7. Pop-Up menus have been a sore point on Macintosh for many years. At first it was because they demanded a fair amount of coding. Later in System 7, they presented backward compatibility issues because some nice “System 7-only” features arrived that were not available on System 6.
  8.  
  9. Tools Plus gives you a consistent set of features across all systems without using custom CDEFs or MDEFs. It also adds features that are not available in Apple’s pop-up menus, like a selectable “disabled” appearance, displaying the selected item’s icon, a “one item only” option, and a “pop-down” menu option.
  10.  
  11. This tutorial shows you how to:
  12.    • create a regular pop-up menu
  13.    • create a pull-down menu
  14.    • create a pop-up menu using a different font (Geneva 9pt)
  15.    • respond to Tools Plus events pertaining to pop-up menus
  16.  
  17. In places where icons are added to a pop-up menu, we’ve included a color ‘cicn’ icon as well as an equivalent black and white ‘SICN’ icon. Macintoshes without Color QuickDraw (like the Mac Plus) have a Menu Manager that ignores color icons, so the ‘SICN’ is there for their sake. Macintoshes _with_ Color QuickDraw use the color ‘cicn’ even if the monitor is set to black and white (they just display the black and white component of the ‘cicn’ color icon).
  18.  
  19.  
  20.  
  21.  
  22.  
  23. The Event Loop
  24. ~~~~~~~~~~~~
  25. The only event you need to be aware of when processing pop-up menus is doPopUpMenu (user has selected an item in a pop-up menu). Your application simply responds to the item selected by the user.
  26.  
  27. Tools Plus takes care of the user clicking in the menu, as well as refreshing the pop-up menu when required.
  28.  
  29.  
  30.  
  31.  
  32.  
  33. Cheating (a bit)
  34. ~~~~~~~~~~~~
  35. The perfect pop-up menu height can be calculated by calling the toolbox’s GetFontInfo and using the FontInfo record (theHeight = FInfo.ascent + FInfo.descent + FInfo.leading). This “perfect height” ensures that the selected item in the control lines up with the highlighted title external to the control.
  36.  
  37. Tools Plus always tries to make your job easier, so instead of you having to calculate the perfect height for each pop-up menu, the pop-up menu does it for you if when you specify that the bottom co-ordinate of the pop-up menu is the same as the top co-ordinate. The following line of code demonstrates this:
  38.                 NewPopUp(myPopUp, 110, 70, 216, 70…
  39.  
  40. When NewPopUp sees that the top and bottom co-ordinates are the same (in this case 70), it calculates the perfect height for the specified font, and creates the pop-up menu using the top co-ordinate you specified (the bottom one is moved downward by the font’s height).
  41.